<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>spade.pyratemp.PseudoSandbox</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="spade-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://spade2.googlecode.com">SPADE</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="spade-module.html">Package&nbsp;spade</a> ::
        <a href="spade.pyratemp-module.html">Module&nbsp;pyratemp</a> ::
        Class&nbsp;PseudoSandbox
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="spade.pyratemp.PseudoSandbox-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class PseudoSandbox</h1><p class="nomargin-top"><span class="codelink"><a href="spade.pyratemp-pysrc.html#PseudoSandbox">source&nbsp;code</a></span></p>
<center>
<center>  <map id="uml_class_diagram_for_spade_py_83" name="uml_class_diagram_for_spade_py_83">
<area shape="rect" id="node2357" href="spade.pyratemp.PseudoSandbox-class.html#eval_allowed_globals" title="spade.pyratemp.PseudoSandbox.eval_allowed_globals" alt="" coords="17,31,161,49"/>
<area shape="rect" id="node2357" href="spade.pyratemp.PseudoSandbox-class.html#__init__" title="spade.pyratemp.PseudoSandbox.__init__" alt="" coords="17,52,161,71"/>
<area shape="rect" id="node2357" href="spade.pyratemp.PseudoSandbox-class.html#register" title="Add an object to the &quot;allowed eval&#45;globals&quot;." alt="" coords="17,71,161,89"/>
<area shape="rect" id="node2357" href="spade.pyratemp.PseudoSandbox-class.html#compile" title="Compile a python&#45;eval&#45;expression." alt="" coords="17,89,161,108"/>
<area shape="rect" id="node2357" href="spade.pyratemp.PseudoSandbox-class.html#eval" title="Eval a python&#45;eval&#45;expression." alt="" coords="17,108,161,127"/>
<area shape="rect" id="node1" href="spade.pyratemp.PseudoSandbox-class.html" title="A pseudo&#45;eval&#45;sandbox." alt="" coords="5,6,173,133"/>
<area shape="rect" id="node2" href="spade.pyratemp.TemplateEval-class.html" title="PseudoSandbox with some additional functions, which are useful in the template." alt="" coords="31,153,148,191"/>
</map>
  <img src="uml_class_diagram_for_spade_py_83.gif" alt='' usemap="#uml_class_diagram_for_spade_py_83" ismap="ismap" class="graph-without-title" />
</center>
</center>
<hr />
<pre class="literalblock">
A pseudo-eval-sandbox.

- Allow only some of the builtin python-functions
  (see eval_allowed_globals), which are considered &quot;save&quot;.
- Forbid names beginning with &quot;_&quot;.
  This is to prevent things like '0 .__class__', with which you could
  easily break out of a &quot;sandbox&quot;.

Note that this is no real sandbox!
Don't use it for untrusted code!!

</pre>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__init__"></a><span class="summary-sig-name">__init__</span>(<span class="summary-sig-arg">self</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.pyratemp-pysrc.html#PseudoSandbox.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.pyratemp.PseudoSandbox-class.html#register" class="summary-sig-name">register</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">name</span>,
        <span class="summary-sig-arg">obj</span>)</span><br />
      Add an object to the &quot;allowed eval-globals&quot;.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.pyratemp-pysrc.html#PseudoSandbox.register">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.pyratemp.PseudoSandbox-class.html#compile" class="summary-sig-name">compile</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">expr</span>)</span><br />
      Compile a python-eval-expression.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.pyratemp-pysrc.html#PseudoSandbox.compile">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.pyratemp.PseudoSandbox-class.html#eval" class="summary-sig-name">eval</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">expr</span>,
        <span class="summary-sig-arg">locals</span>)</span><br />
      Eval a python-eval-expression.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.pyratemp-pysrc.html#PseudoSandbox.eval">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== CLASS VARIABLES ==================== -->
<a name="section-ClassVariables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Class Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-ClassVariables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="spade.pyratemp.PseudoSandbox-class.html#eval_allowed_globals" class="summary-name">eval_allowed_globals</a> = <code title="{'False': False,
 'None': None,
 'True': True,
 'abs': &lt;built-in function abs&gt;,
 'bool': &lt;type 'bool'&gt;,
 'chr': &lt;built-in function chr&gt;,
 'cmp': &lt;built-in function cmp&gt;,
 'complex': &lt;type 'complex'&gt;,
..."><code class="variable-group">{</code><code class="variable-quote">'</code><code class="variable-string">False</code><code class="variable-quote">'</code><code class="variable-op">: </code>False<code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">None</code><code class="variable-quote">'</code><code class="variable-op">: </code>None<code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">True</code><code class="variable-quote">'</code><code class="variable-op">: </code><code class="variable-ellipsis">...</code></code>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="register"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">register</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">name</span>,
        <span class="sig-arg">obj</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.pyratemp-pysrc.html#PseudoSandbox.register">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Add an object to the &quot;allowed eval-globals&quot;.</p>
  <p>Mainly useful to add user-defined functions to the pseudo-sandbox.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="compile"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">compile</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">expr</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.pyratemp-pysrc.html#PseudoSandbox.compile">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">
Compile a python-eval-expression.

- Use a compile-cache
- Raise an NameError if expr contains a name beginning with '_'.

:Returns: the compiled expr
:Raises: SyntaxError for compile-errors,
         NameError if expr contains a name beginning with '_'

</pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="eval"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">eval</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">expr</span>,
        <span class="sig-arg">locals</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.pyratemp-pysrc.html#PseudoSandbox.eval">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Eval a python-eval-expression.</p>
  <p>Uses the compile-cache.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== CLASS VARIABLE DETAILS ==================== -->
<a name="section-ClassVariableDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Class Variable Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-ClassVariableDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="eval_allowed_globals"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">eval_allowed_globals</h3>
  
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-group">{</code><code class="variable-quote">'</code><code class="variable-string">False</code><code class="variable-quote">'</code><code class="variable-op">: </code>False<code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">None</code><code class="variable-quote">'</code><code class="variable-op">: </code>None<code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">True</code><code class="variable-quote">'</code><code class="variable-op">: </code>True<code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">abs</code><code class="variable-quote">'</code><code class="variable-op">: </code>&lt;built-in function abs&gt;<code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">bool</code><code class="variable-quote">'</code><code class="variable-op">: </code>&lt;type 'bool'&gt;<code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">chr</code><code class="variable-quote">'</code><code class="variable-op">: </code>&lt;built-in function chr&gt;<code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">cmp</code><code class="variable-quote">'</code><code class="variable-op">: </code>&lt;built-in function cmp&gt;<code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">complex</code><code class="variable-quote">'</code><code class="variable-op">: </code>&lt;type 'complex'&gt;<code class="variable-op">,</code>
<code class="variable-ellipsis">...</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="spade-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://spade2.googlecode.com">SPADE</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Wed Aug  1 18:44:55 2012
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
